using System;
using System.Collections;
using System.Threading;
using System.Runtime.CompilerServices;
using Microsoft.SPOT.Hardware;
using System.IO.Ports;

namespace Microsoft.SPOT.Hardware.HAG
{

    /// <summary>
    /// Specifies identifiers for hardware I/O pins.
    /// </summary>
    public static class Pins
    {
        public const Cpu.Pin GPIO_PORT_SPI1_ISO       = (Cpu.Pin)0;//PA0
        public const Cpu.Pin GPIO_PORT_SPI1_OSI       = (Cpu.Pin)1;//PA1
        public const Cpu.Pin GPIO_PORT_SPI1_MSK       = (Cpu.Pin)2;//PA2
	
        public const Cpu.Pin GPIO_PORT_DATAFLASH_CS   = (Cpu.Pin)3;//PA3
		public const Cpu.Pin GPIO_PORT_SDCARD_CS      = (Cpu.Pin)4;//PA4
		public const Cpu.Pin GPIO_PORT_OLED_CS        = (Cpu.Pin)5;//PA5
		public const Cpu.Pin GPIO_PORT_OLED_RS        = (Cpu.Pin)6;//PA6

        public const Cpu.Pin GPIO_PORT_I2C_SDA        = (Cpu.Pin)7;//PA7
        public const Cpu.Pin GPIO_PORT_I2C_SCL        = (Cpu.Pin)8;//PA8
		
        public const Cpu.Pin GPIO_PORT_DEBUG_RX	      = (Cpu.Pin)9;//PA9
        public const Cpu.Pin GPIO_PORT_DEBUG_TX       = (Cpu.Pin)10;//PA10
		
        public const Cpu.Pin GPIO_PORT_DISPON         = (Cpu.Pin)12;  
        public const Cpu.Pin GPIO_PORT_PEN            = (Cpu.Pin)37;
        public const Cpu.Pin GPIO_PORT_SDCARD_CD      = (Cpu.Pin)38;//PB6 
        public const Cpu.Pin GPIO_PORT_CC2420_FIFOP   = (Cpu.Pin)45;//PB13
        public const Cpu.Pin GPIO_PORT_CC2420_CCA     = (Cpu.Pin)46;//PB14
        public const Cpu.Pin GPIO_PORT_CC2420_SFD     = (Cpu.Pin)53;//PB21
        public const Cpu.Pin GPIO_PORT_CC2420_VREG_EN = (Cpu.Pin)54;//PB22
		
        public const Cpu.Pin GPIO_PORT_SPI2_MSK       = (Cpu.Pin)61;//PB29
        public const Cpu.Pin GPIO_PORT_SPI2_ISO       = (Cpu.Pin)62;//PB30
        public const Cpu.Pin GPIO_PORT_SPI2_OSI       = (Cpu.Pin)63;//PB31
		
        public const Cpu.Pin GPIO_PORT_PGOOD          = (Cpu.Pin)66;
        public const Cpu.Pin GPIO_PORT_KBD_INT        = (Cpu.Pin)69;
		
        public const Cpu.Pin GPIO_PORT_USART_TX0      = (Cpu.Pin)72;//PC8
        public const Cpu.Pin GPIO_PORT_USART_RX0      = (Cpu.Pin)73;//PC9
        public const Cpu.Pin GPIO_PORT_NFC_IRQ        = (Cpu.Pin)74;//PC10        
		
        public const Cpu.Pin GPIO_PORT_USART_TX1      = (Cpu.Pin)75;//PC12
        public const Cpu.Pin GPIO_PORT_USART_RX1      = (Cpu.Pin)76;//PC13
        
		public const Cpu.Pin GPIO_PORT_CC2420_FIFO    = (Cpu.Pin)78;
        public const Cpu.Pin GPIO_PORT_CC2420_CS      = (Cpu.Pin)79;//PC15
			
		public const Cpu.Pin GPIO_PORT_BUTTON_0       = (Cpu.Pin)96;//I2C
		public const Cpu.Pin GPIO_PORT_BUTTON_1       = (Cpu.Pin)97;//I2C
		public const Cpu.Pin GPIO_PORT_BUTTON_2       = (Cpu.Pin)98;//I2C
		public const Cpu.Pin GPIO_PORT_BUTTON_3       = (Cpu.Pin)99;//I2C

		public const Cpu.Pin GPIO_PORT_LED_0       	  = (Cpu.Pin)100;//I2C
		public const Cpu.Pin GPIO_PORT_LED_1       	  = (Cpu.Pin)101;//I2C
		public const Cpu.Pin GPIO_PORT_LED_2          = (Cpu.Pin)102;//I2C
		// 103 reserved 
		public const Cpu.Pin GPIO_PORT_COM4_CTS	  	  = (Cpu.Pin)104;//XR16l784
		public const Cpu.Pin GPIO_PORT_COM7_CTS	  	  = (Cpu.Pin)105;//XR16l784
		public const Cpu.Pin GPIO_PORT_COM7_DSR	  	  = (Cpu.Pin)106;//XR16l784
		public const Cpu.Pin GPIO_PORT_COM7_DCD	  	  = (Cpu.Pin)107;//XR16l784
		public const Cpu.Pin GPIO_PORT_COM7_RI	  	  = (Cpu.Pin)108;//XR16l784
		// 109,110,111 reserved 
		public const Cpu.Pin GPIO_PORT_COM4_RTS	  	  = (Cpu.Pin)112;//XR16l784
		public const Cpu.Pin GPIO_PORT_COM6_DUPLEX	  = (Cpu.Pin)113;//XR16l784
		public const Cpu.Pin GPIO_PORT_COM7_RTS	  	  = (Cpu.Pin)114;//XR16l784
		public const Cpu.Pin GPIO_PORT_COM7_DTR	  	  = (Cpu.Pin)115;//XR16l784
		

        public const Cpu.Pin GPIO_NONE = Cpu.Pin.GPIO_NONE;		
    }

    public static class SerialPorts
    {
        public const string COM1 = "COM1";
        public const string COM2 = "COM2";
        public const string COM3 = "COM3";
        public const string COM4 = "COM4";
        public const string COM5 = "COM5";
        public const string COM6 = "COM6";
        public const string COM7 = "COM7";

        // AT91-D, Serial Debug (RS232), HAGMAIN X29 
        public const string DEBUGGER = COM1;
        // AT91-0, HAGRFBUS NFC-Modul, HAGMAIN X200
        public const string HAGRF_NFC = COM2;
        // AT91-1, KNX/LON Module, HAGMAIN X20
        public const string HAGMAIN_KNX = COM3;
        // XR16L784-0, HAGRFBUS BLUETOOTH, HAGMAIN X200
        public const string HAGRF_BLUETOOTH = COM4;
        // XR16L784-1, RS485, Interface HAGPSIO, HAGMAIN X100
        public const string HAGPSIO = COM5;
        // XR16L784-2, SER5 (RS485), HAGMAIN X24
        public const string HAGMAIN_RS485 = COM6;
        // XR16L784-3, SER6 (RS232), HAGMAIN X23
        public const string HAGMAIN_RS232 = COM7;
    }
    
    public static class BaudRates
    {
        public const BaudRate Baud19200  = BaudRate.Baudrate19200;
        public const BaudRate Baud38400  = BaudRate.Baudrate38400;
        public const BaudRate Baud57600  = BaudRate.Baudrate57600;
        public const BaudRate Baud115200 = BaudRate.Baudrate115200;
        public const BaudRate Baud230400 = BaudRate.Baudrate230400;
    }

    public static class ResistorModes
    {
        public const Port.ResistorMode PullUp   = Port.ResistorMode.PullUp;
        public const Port.ResistorMode Disabled = Port.ResistorMode.Disabled;
    }

    public static class InterruptModes
    {
        public const Port.InterruptMode InterruptEdgeLow       = Port.InterruptMode.InterruptEdgeLow ;
        public const Port.InterruptMode InterruptEdgeHigh      = Port.InterruptMode.InterruptEdgeHigh;
        public const Port.InterruptMode InterruptEdgeBoth      = Port.InterruptMode.InterruptEdgeBoth;
        public const Port.InterruptMode InterruptEdgeLevelHigh = Port.InterruptMode.InterruptEdgeLevelHigh;
        public const Port.InterruptMode InterruptEdgeLevelLow  = Port.InterruptMode.InterruptEdgeLevelLow;
        public const Port.InterruptMode InterruptNone          = Port.InterruptMode.InterruptNone;
    }

    public static class SPI_Devices
    {
        //public const Microsoft.SPOT.Hardware.SPI.SPI_module SPI1 = Microsoft.SPOT.Hardware.SPI.SPI_module.SPI1;

		public const SPI.SPI_module SPI1 = SPI.SPI_module.SPI1;
		public const SPI.SPI_module SPI2 = SPI.SPI_module.SPI2;

	}
    
}
